/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ace.geometry;

/**
 *
 * @author Hallucinogen
 */
public class Vertex2D {
	public Vertex2D() {
		x = 0;
		y = 0;
	}

	public Vertex2D(float inX, float inY) {
		x = inX;
		y = inY;
	}

	public Vertex2D(Vertex2D otherVertex) {
		x = otherVertex.x;
		y = otherVertex.y;
	}

	public void zero() {
		x = 0;
		y = 0;
	}

	public void invert() {
		x = -x;
		y = -y;
	}

	public static Vertex2D add(Vertex2D v1, Vertex2D v2) {
		return new Vertex2D(v1.x + v2.x, v1.y + v2.y);
	}

	public static float range(Vertex2D v1, Vertex2D v2) {
		final float dx = v1.x - v2.x;
		final float dy = v1.y - v2.y;

		return (float)Math.sqrt(dx * dx + dy * dy);
	}

	public void add(Vertex2D v) {
		x += v.x;
		y += v.y;
	}

	public void add(Vector2D v) {
		x += v.x;
		y += v.y;
	}

	public String toString() {
		return "(" + x + ", " + y + "}";
	}

	public float x;
	public float y;
}
